<?php
$dom = new DOMDocument('1.0', 'UTF-8');

$root = $dom->createElementNS('http://zend.loc', 'zend:document');
$dom->appendChild($root);

// convert in SimpleXML

$xml = simplexml_import_dom($dom);

// add information
$xml->addChild('matches', count($this->result));
$xml->addChild('searchTime', time());

// result search
$res = $xml->addChild('res');
foreach ($this->res as $r)
{
	$result = $res->addChild('result');
	$result->addChild('score', $r->score);
	$result->addChild('id', $r->RecordID);
	$result->addChild('title', $r->Title);
	$result->addChild('year', $r->Year);
	$result->addChild('grade', $r->Grade);
	$result->addChild('country', $r->Country);
	$price = $result->addChild('price');
	$price->addChild('min', $r->SalePriceMin);
	$price->addChild('max', $r->SalePriceMax);
}

	echo $xml->asXML();
?>